<?php

	/*
	 * DB Operations Script
	 *  By Chris Leung
	 */

	class dbController {
		
		var $db;
		
		function dbController($DB_CONNECT) {
			$this->__construct($DB_CONNECT);
		}
		
		function __construct($DB_CONNECT) {
			require_once('DB.php');
			$this->db = DB::connect($DB_CONNECT);
			if (DB::iserror($this->db)) {
					die($this->db->getMessage());
			}
		}
		
		function query($SQL) {
			$results = $this->db->query($SQL);
			
			if (DB::iserror($results)) {
					die($results->getMessage() . "<br>" . $SQL);
			}

			return $results;
		}

		function getOne($SQL) {
			$result = $this->db->getOne($SQL);
			
			if (DB::iserror($result)) {
					die($result->getMessage() . "<br>" . $SQL);
			}
			
			return $result;
		}

		function getRow($SQL) {
			$result = $this->db->getRow($SQL);
			
			if (DB::iserror($result)) {
					die($result->getMessage() . "<br>" . $SQL);
			}
			
			return $result;
		}

	}

?>
